<!--
 * @Descripttion: 
 * @version: 
 * @Author: cyj
 * @Date: 2023-02-13 19:09:14
-->
<template>
    <!-- 封装分页器 -->
    <div class="page">
        <el-pagination :total="props.total" :current-page="props.currentPage" :page-size="props.pageSize"
            @current-change="handleCurrentChange" :layout="props.layout" background small>
        </el-pagination>
    </div>
</template>

<script setup>
const props = defineProps({
    total: {
        required: true,
        type: Number
    },
    pageSize: {
        required: true,
        type: Number
    },
    currentPage: {
        type: Number,
        default: 1,
    },
    scrollTop: {
        type: Boolean,
        default: true,
    },
    layout: {
        type: String,
        default: "total, prev, pager, next",
    },
})
const emit = defineEmits(['handleCurrentChange'])

function handleCurrentChange(page) {
    emit('handleCurrentChange', page)  //触发自定义事件
    if (props.scrollTop){
        console.log(document.querySelector('.view'));
        document.querySelector('.view').scrollTop = 0  //滚动到顶部

    }
}
</script>

<style lang="scss" scoped>

</style>